package com.msconfig.mvp.view.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;

import com.geo.msconfig.R;
import com.msconfig.event.WorkerHoursDialogDismissEvent;
import com.msconfig.mvp.view.adapter.TimeZoneAdapter;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;

public class SetupSurveyWorkerHoursDialogActivity extends Activity {

    private ListView lvTimeZone;
    private ArrayList<String> arrayList;
    private TimeZoneAdapter adapter;
    private TextView title;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_activity_setup_worker_hours_dialog);
        lvTimeZone=findViewById(R.id.lv_time_zone);
        title=findViewById(R.id.title);
        arrayList=new ArrayList<>();
        title.setText(R.string.title_work_hours);
        arrayList.add(getString(R.string.text_hour_2));
        arrayList.add(getString(R.string.text_hour_4));
        arrayList.add(getString(R.string.text_hour_8));
        arrayList.add(getString(R.string.text_hour_12));
        arrayList.add(getString(R.string.text_hour_24));
        adapter=new TimeZoneAdapter(this,arrayList);
        lvTimeZone.setAdapter(adapter);
        lvTimeZone.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                TextView tvName=view.findViewById(R.id.tv_name);
                String strName=tvName.getText().toString().trim();
                //更新参数设置页面
                EventBus.getDefault().post(new WorkerHoursDialogDismissEvent(strName));
                finish();
            }
        });
    }

}
